//
//  UIViewController+NavBar.m
//  YJFinancial
//
//  Created by David Qu on 14-6-3.
//  Copyright (c) 2014年 David Qu Studio. All rights reserved.
//

#import "UIViewController+NewNavBar.h"
#import "UIColor+SNFoundation.h"

@implementation UIViewController (NewNavBar)

- (void)updateNewNavBar
{
    //top_tm.png Nvb-1.png
    UIImage *backgroundImage = [UIImage imageNamed:@"Nvb-1.png"];
    if (IOS_VERSION >= 7.0) {
        [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
        [[UINavigationBar appearance] setTitleTextAttributes:
         @{NSForegroundColorAttributeName : [UIColor whiteColor]}
         ];
        [self.navigationController.navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
        [self.navigationController.navigationBar setTranslucent:NO];
        [self.navigationController.navigationBar setTitleTextAttributes:
         @{NSFontAttributeName:[UIFont systemFontOfSize:16],
           NSForegroundColorAttributeName:[UIColor whiteColor]}];
    }
    else
    {
        [self.navigationController.navigationBar insertSubview:[[UIImageView alloc] initWithImage:backgroundImage] atIndex:1];
        [[[self navigationController] navigationBar] setNeedsLayout];
        [self.navigationController.navigationBar setTitleTextAttributes:
         @{NSFontAttributeName:[UIFont systemFontOfSize:16],
           NSForegroundColorAttributeName:[UIColor whiteColor]}];
    }
}

@end
